package main

import (
	"flag"
	"fmt"
)

//命令test.exe -u root -pwd root -h 192.168.1.1 -port 3306
func main() {
	var user string
	var pwd string
	var host string
	var port int

	flag.StringVar(&user, "u", "", "用户名默认为空")
	flag.StringVar(&pwd, "pwd", "", "密码是空")
	flag.StringVar(&host, "h", "localhost", "主机默认是localhost")
	flag.IntVar(&port, "port", 3321, "默认端口是3321")

	//这是很重要的操作，转换，必须调用该方法
	flag.Parse()

	fmt.Println(user, pwd, host, port)
}